package com.wang.helloworld.hellojetty.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

@Configuration
@ComponentScan(basePackages = {
        "com.wang.helloworld.hellojetty.a",
        "com.wang.helloworld.hellojetty.b"
})
@Import(SecurityConfig.class)
public class ApplicationConfig {
	/*private static final Resource[] DEV_PROPERTIES = new ClassPathResource[]{
        new ClassPathResource("hellojetty-dev.properties"),
	};
	private static final Resource[] TEST_PROPERTIES = new ClassPathResource[]{
		new ClassPathResource("hellojetty-test.properties"),
	};
	private static final Resource[] PROD_PROPERTIES = new ClassPathResource[]{
		new ClassPathResource("hellojetty-prod.properties"),
	};

	@Profile("dev")
	public static class DevConfig {
		@Bean
	    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
	        PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
	        pspc.setLocations(DEV_PROPERTIES);
	        return pspc;
	    }
	}

	@Profile("test")
	public static class TestConfig {
	    @Bean
	    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
	        PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
	        pspc.setLocations(TEST_PROPERTIES);
	        return pspc;
	    }
	}

	@Profile("prod")
	public static class ProdConfig {
	    @Bean
	    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
	        PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
	        pspc.setLocations(PROD_PROPERTIES);
	        return pspc;
	    }
	}*/
}
